﻿using System;
using System.Collections.Generic;
using System.IO;

namespace PythonModPacker
{
    class ModPackInfo
    {
        public String behaviorPack = "";
        public String resourcePack = "";
        public String rootPath;

        public ModPackInfo(String rootPath)
        {
            this.rootPath = rootPath;
            DirectoryInfo directory = new DirectoryInfo(rootPath);
            foreach(DirectoryInfo subFolder in directory.GetDirectories()) {
                var name = subFolder.Name;
                if (name.Contains("Beh")|| name.Contains("beh"))
                {
                    behaviorPack = name;
                    continue;
                }
                if (name.Contains("Res") || name.Contains("res"))
                {
                    resourcePack = name;
                }
            }
        }

        public String[] getFilter()
        {
            return new String[]{ Path.Combine(rootPath,behaviorPack),Path.Combine(rootPath,resourcePack)};
        }

        public override bool Equals(object obj)
        {
            return obj is ModPackInfo info &&
                   behaviorPack == info.behaviorPack &&
                   resourcePack == info.resourcePack &&
                   rootPath == info.rootPath;
        }

        public override int GetHashCode()
        {
            var hashCode = 437575864;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(behaviorPack);
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(resourcePack);
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(rootPath);
            return hashCode;
        }

        public override string ToString()
        {
            return rootPath;
        }

        public Boolean Validate() => behaviorPack != "" && resourcePack != "";


    }
}
